<template>
	<div>
		<!-- 分类列表 -->
		<div id="slider" class="mui-slider ">
			<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div class="mui-scroll">
					<a :class="['mui-control-item',item.title=='全部'?'mui-active':'']" v-for="item in category" :key="item.id" @tap="getPhotoList(item.id)">
						{{item.title}}
					</a>
				</div>
			</div>
		</div>
		<!-- 图片展示 -->
		<div id="show">
			<ul class="ulphoto">
				<router-link v-for="item in photoList" :key="item.id" class="photo" :to="'/home/photoInfo/'+item.id" tag="li">
					<img v-lazy="item.img_url">
					<div class="con">
						<h1 class="title">{{item.title}}</h1>
						<span class="content" v-html="item.content"></span>
					</div>
				</router-link>
			</ul>
			
		</div>

	</div>

</template>

<script>
	import mui from '../../mui/js/mui.min.js'
	export default {
		data() {
			return {
				category: [],
				photoList: []
			}
		},
		mounted() {
			mui('.mui-scroll-wrapper').scroll({
				deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			});
		},
		created() {
			this.getCategory()
			this.getPhotoList(0)
		},
		methods: {
			getCategory() {
				this.$http.get('http://www.liulongbin.top:3005/api/getimgcategory').then(data => {
					// console.log(data.body)
					if (data.body.status === 0) {
						data.body.message.unshift({
							title: "全部",
							id: 0
						})
						this.category = data.body.message
						// console.log(data.body)
					}
				})
			},
			getPhotoList(id) {
				this.$http.get('http://www.liulongbin.top:3005/api/getimages/' + id).then(data => {
					if (data.body.status === 0) {
						this.photoList = data.body.message
						// console.log(data.body)
					}
				})
			}

		}
	}
</script>

<style scoped="scoped">
img[lazy=loading] {
  width: 40px;
  height: 300px;
  margin: auto;
}
.photo{
	background-color: #CCCCCC;
	margin-bottom: 10px;
	text-align: center;
	box-shadow: 0 0 9px red;
	position: relative;
}
.ulphoto{
	list-style: none;
	padding: 0px 10px;
}
img{
width: 100%;
vertical-align: middle;
}

.con{
	color: white;
	text-align: left;
	position: absolute;
	bottom: 0;
	background-color: rgba(0,0,0,0.4);
	max-height: 84px;
}
.title{
	font-size: 14px;
	
}
.content{
	font-size: 13px;
}
</style>
